package org.sob.blog.controller;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sob.blog.pojo.House;
import org.sob.blog.pojo.User;
import org.sob.blog.response.ResponseResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @RequestMapping(value = "/hello-world", method = RequestMethod.GET)
    public ResponseResult helloWorld() {
        log.info("hello world...");
        return ResponseResult.SUCCESS().setData("hello");
    }

    @GetMapping("/test-json")
    public ResponseResult testJson() {
        User user = new User("特朗普", 73, "male");
        House house = new House("白宫", "华盛顿特区");
        user.setHouse(house);
        return ResponseResult.SUCCESS().setData(user);
    }
}
